﻿
@{
    ViewData["Title"] = "CateringGroup";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h1>菜品分组</h1>
<div>
    <button class="layui-btn" id="add">添加</button>
</div>

@*规格*@
<table class="layui-table" id="demoTable" lay-filter="demoTable">
    <tbody>
        <!-- 这里是动态生成的数据 -->
    </tbody>
</table>
<div id="demo-laypage-all"></div>

@* 标签操作*@
<script type="text/html" id="bardemo">
   
    <a class="layui-btn layui-btn-xs layui-btn-danger layui-btn-action" lay-event="deleteNumber">删除</a>
</script>
<div id="demo-laypage-layout-1"></div>

@*弹框*@
<div id="addModal" style="display:none;">

        <form class="layui-form">
            <div class="layui-form-item" style="display:none">

                <label class="layui-form-label"><span style="color:red">*</span>id</label>
                <div class="layui-input-block">
                    <input type="text" name="dishesGroupId" id="dishesGroupId" placeholder="dishesGroupId">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input type="text" name="dishesGroupName" id="dishesGroupName" lay-verify="required" placeholder="" lay-reqtext="名称" autocomplete="off" class="layui-input">
                </div>
            </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="reset" class="layui-btn layui-btn-primary">取消</button>
                <button class="layui-btn" lay-submit lay-filter="submitForm">确认</button>
                <button class="layui-btn" lay-submit lay-filter="xiuForm">修改</button>
            </div>
        </div>
    </form>
    </div>
    <html>
        <body>
            <script>

        function getSelectedIds() {
            var checkstatus = layui.table.checkstatus('demoTable');
            if (checkstatus.data.length > 0) {
                var idsArray = [];
                for (var i = 0; i < checkstatus.data.length; i++) {
                    idsArray.push(checkstatus.data[i].dishesId);
                }
                var ids = idsArray.toString();
                aler(ids);
            }
            else {

                alert("请至少选着一个");
            }
        }

                layui.use(['table', 'layer', 'form', 'laydate', 'jquery', 'element', 'laypage', 'util'], function () {
                    var table = layui.table;
                    var layer = layui.layer;
                    var form = layui.form;
                    var laydate = layui.laydate;
                    var $ = layui.jquery;
                    var element = layui.element;
                    var util = layui.util;
                    var laypage = layui.laypage;

                    $(function () {

                        Show();
                    })

                    var from = {
                        dishesGroupName: "",
                        dishesGroupId: ""
                    }

                    function Show() {
                        $.ajax({
                            url: "http://localhost:5174/api/CateringGroup/GroupShow",
                            type: "post",
                            data: JSON.stringify(from),
                            contentType: "application/json",
                            headers: {
                                "Authorization": "Bearer " + localStorage.getItem("token")
                            },
                            async: true,
                            success: res => {
                                console.log(res.data);
                                table.render({
                                    elem: '#demoTable'
                                    , data: res.data
                                    , cols: [[

                                        { field: 'dishesGroupName', title: '名称', width: 100 },
                                        { toolbar: '#bardemo', title: '操作' },
                                    ]]
                                });
                            },
                            error: function (res) {
                                console.log(res);

                            }
                        })
                    }

                });



                


            </script>
        </body>

    </html>


